<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>浅拷贝问题</title>
</head>

<body>
  <script> const obj = {
      uname: '张三',
      age: 14,
      family: {
        faName: '宝宝'
      }
    }
    const o = { ...obj }
    o.age = 20
    o.family.faName = '哈哈哈'
    console.log(o);
    console.log(obj);

    // 问题:
    // 浅拷贝只拷贝最外面一层,如果遇到里面的一层family,修改值时就会影响到原来的对象
  </script>
</body>

</html>